package com.junjie.services.impl;

import com.junjie.dao.UserDao;
import com.junjie.entity.User;
import com.junjie.services.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;

    //返回登陆用户的信息
    @Override
    public User getUserByUsername(String username) {
        return userDao.getUserByUsername(username);
    }

    //根据用户名来查询菜单
    @Override
    public String getMenuByUserName(String username) {
        return userDao.getMenuByUserName(username);
    }

    //通用的查询接口
    @Override
    public List<User> getUsersByEntity(User user) {
        return userDao.getUserByEntity(user);
    }

    //增加一条用户信息
    @Override
    public int insertUser(User user) {
        return userDao.addUser(user);
    }

    //修改用户的信息
    @Override
    public int updateUser(User user) {
        return userDao.updateByUserId(user);
    }

    //删除一条用户的信息
    @Override
    public int deleteUser(Integer id) {
        return userDao.deleteUserById(id);
    }
}
